# Paper Trading Simulator
A browser-based paper trading simulator that connects to the Alpaca Markets API. ## Prerequisites
- A web server with PHP 7.0+
- An Alpaca account (sign up at https://alpaca.markets/) - API key and secret from Alpaca (paper trading account)
## Installation
1. Upload all three files to your web server
2. Edit `config.php` and add your Alpaca API credentials:
```php
define('ALPACA_API_KEY', 'your_actual_api_key_here'); define('ALPACA_API_SECRET', 'your_actual_api_secret_here');
3. Changethesecuritytokeninbothconfig.phpandtheHTMLfile:
o In config.php: define('API_TOKEN', 'your_secure_random_token_here'); o In the HTML file: token: 'your_secure_random_token_here' (line ~95)
4. OpentheHTMLfileinyourwebbrowser Usage
Account Setup
The simulator uses your Alpaca paper trading account. All trades are simulated with virtual funds.
Placing Orders
1. Enterastocksymbolinthe"Symbol"field

2. Specifythequantity
3. Chooseordertype(market,limit,stop,stoplimit) 4. Click"Buy"or"Sell"toplacetheorder
Viewing Positions
Your current positions are displayed in the "Open Positions" section with real-time profit/loss information.
Order History
All placed orders appear in the "Order History" table with their status and execution details. Features
• Real-time market data through Alpaca API
• Paper trading with virtual funds
• Multiple order types (market, limit, stop, stop limit)
• Portfolio tracking with P/L calculations
• Order history
• Basic automated trading strategies (experimental)
Security Notes
• Keep your config.php file secure and never share it
• Use a strong, random token for API communication
• The application runs client-side, but API calls are proxied through your server
Troubleshooting Common Issues
1. APIerrors:VerifyyourAlpacaAPIkeysarecorrect
2. CORSerrors:Ensureallfilesareonthesamedomain
3. Orderfailures:Checkifthemarketisopenforthesymbolyou'retrading
Getting Help
If you encounter issues:
1. Checkthebrowserconsoleforerrormessages

2. VerifyyourAlpacaaccounthaspapertradingenabled
3. EnsureyourserverhasPHPenabledandcanmakeexternalHTTPrequests Disclaimer
This is a simulation tool for educational purposes only. Not investment advice. Trading real money involves risk.
